<template>
  <div class="list-container">
    <!-- 劳务公司发放记录 -->
    <!-- <el-form class="search-panel" v-model="searchData" :inline="true">
      <el-form-item
        label-width="120px"
        class="search-time"
        label="考勤时间："
        prop="startToEnd"
      >
        <el-date-picker
          style="width: 250px"
          v-model="searchData.startToEnd"
          type="monthrange"
          range-separator="~"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form> -->
    <div class="table-panel">
        <!-- <el-row class="table-operate">
        <el-button @click="exportItems">
          导出 <i class="el-icon-upload2" />
        </el-button>
      </el-row> -->
      <el-table :data="tableData" style="width: 100%">
        <el-table-column
          prop="id"
          type="index"
          label="序号"
          width="60"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
          prop="payDate"
          label="发放时间"
          align="center"
        >
          <template slot-scope="scope">
            <div>{{ scope.row.payDate }}</div>
          </template>
        </el-table-column> -->
        <!-- <el-table-column prop="serviceCorporationName" label="劳务公司名称" align="center">
        </el-table-column> -->
        <el-table-column prop="attendanceDate" label="考勤月份" align="center">
        </el-table-column>
        <el-table-column prop="attendanceNum" label="考勤人数" align="center">
        </el-table-column>
        <el-table-column prop="referenceMonthlyWageTotal" label="参考工资合计" align="center">
          <template slot-scope="scope">
            <div>¥{{ scope.row.referenceMonthlyWageTotal }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="actualMonthWageTotal" label="实际工资合计" align="center">
          <template slot-scope="scope">
            <div>¥{{ scope.row.actualMonthWageTotal }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="issuedMonthlyWage" label="已发放金额" align="center">
          <template slot-scope="scope">
            <div>¥{{ scope.row.issuedMonthlyWage }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="unissuedMonthlyWage"
          label="未发放金额"
          align="center"
        >
          <template slot-scope="scope">
            <div>¥{{ scope.row.unissuedMonthlyWage }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="发放状态" align="center">待银行发放</el-table-column>
        <!-- <el-table-column
          prop="operation"
          label="操作"
          align="center"
        >
          <template slot-scope="scope">
            <el-button
              @click="checkedRow(scope.row)"
              type="text"
              icon="el-icon-search"
              >查看</el-button
            >
          </template>
        </el-table-column> -->
      </el-table>
      <el-row class="page">
        <div class="page-tag">
          共{{ Math.ceil(1 / pageSize) }}页/{{ 1 }}条数据
        </div>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-sizes="[10, 20, 50]"
          :page-size="pageSize"
          layout="sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-row>
    </div>
  </div>
</template>

<script>
import { monthWageList } from "@/api/monthlyWage";
import workflowApi from '@/api/workflow/workFlow'
export default {
  data() {
    return {
      searchData: {
        startToend: null,
      },
      tableData: [],
      total: 0,
      pageSize: 10,
      currentPage: 1,
    };
  },
  created(){
    //this.getTableData()
    this.getTableData()
  },
  methods: {
    getTableData(){
      monthWageList({
      currentPage:this.currentPage,
      pageSize:this.pageSize,
      // startDate:this.formData.startToEnd==null?null:this.formData.startToEnd[0],
      // endDate:this.formData.startToEnd==null?null:this.formData.startToEnd[1],
      serviceCorporationId: this.companyId
    }).then(res=>{
      //totalData总数没传
      console.log(res.data.data.records);
      this.tableData = res.data.data.records
      var tableData = []
      res.data.data.records.forEach(item=>{
        if(item.attendanceDate=='2021-07'){
          tableData.push(item)
        }
      })
      this.tableData = tableData 
      // res.data.data.records.forEach(item=>{
      //   var tableData1 = {}
      //   tableData1.attendanceTime=item.attendanceDate
      //   tableData1.attendanceNum=item.attendanceNum
      //   tableData1.referenceMonthlyWage=item.referenceMonthlyWageTotal
      //   tableData1.realMonthlyWage=item.actualMonthWageTotal
      //   tableData.push(tableData1)
      // })
      })
    },
    onSubmit() {
      this.searchData.startDate = this.searchData.startToEnd[0]
      this.searchData.endDate = this.searchData.startToEnd[1]
      this.getTableData()
      console.log(this.searchData);
    },
    // 导出
    exportItems(){

    },
    // 查看
    checkedRow(res) {
      console.log("-----------------")
      console.log(res)
      // this.$router.push({path:'/agency/issuanceRecord',query:{workflowApplyId:res.workflowApplyId,date:res.attendanceTime}})
    },
    // 发放
    // issuanceRow(date) {},
    handleSizeChange(val) {
      this.searchData.pageSize = val
      this.getTableData()
    },
    handleCurrentChange(val) {
      this.searchData.currentPage = val
      this.getTableData()
    },
    // convertStatus(status){
    //   let newStatus = "未知"
    //   switch (status){
    //     case '1': newStatus = "待审核";break;
    //     case '2': newStatus = "审核中";break;
    //     case '3': newStatus = "已审核";break;
    //     case '4': newStatus = "已驳回";break;
    //     case '5': newStatus = "已撤回";break;
    //   }
    //   return newStatus
    // }
  },
};
</script>
